package com.myapp.model.impl.user;

import org.mybatis.spring.SqlSessionTemplate;
import com.myapp.model.dao.user.UserDao;
import com.myapp.model.entity.user.User;

public class UserDaoImpl implements UserDao {

	private SqlSessionTemplate sqlDao;
	
	@Override
	public User addUser(User user) {
		if(user == null)
		{
			return null;
		}
		
		int id = sqlDao.insert("user.addUser", user);
		user.setUserId(id);
		return user;
	}
	
	public User getUser(User user)
	{
		if(user == null)
		{
			return null;
		}
		return (User)sqlDao.selectOne("user.getOneUser", user);
	}

	public SqlSessionTemplate getSqlDao() {
		return sqlDao;
	}

	public void setSqlDao(SqlSessionTemplate sqlDao) {
		this.sqlDao = sqlDao;
	}
}
